package com.chtw.oasystem.common.response;

import lombok.Data;

@Data
public class RespUtils<T> {
    private int code;
    private String msg;
    private T data;

    private RespUtils(int code, String msg) {
        this.code = code;
        this.msg = msg;
        this.data = null;
    }

    private RespUtils(T data) {
        this.code = CodeAndMsg.SUCCESS.getCode();
        this.msg = CodeAndMsg.SUCCESS.getMessage();
        this.data = data;
    }

    public static <T> RespUtils<T> success(T data) {
        return new RespUtils<>(data);
    }

    public static <T> RespUtils<T> fail(String msg) {
        return new RespUtils<>(CodeAndMsg.FAIL.getCode(), msg);
    }

    public static<T> RespUtils<T>  NotLoginFail(){
        return new RespUtils<>(29, "用户未登录！");
    }
}

